package util;

import domain.Result;

import java.util.HashMap;
import java.util.Random;

public class RandomUtil {
    public Result getResult(){
        HashMap<Integer,Integer> nums = new HashMap<>();
        //初始化六个点数
        nums.put(1,0);
        nums.put(2,0);
        nums.put(3,0);
        nums.put(4,0);
        nums.put(5,0);
        nums.put(6,0);

        //构造随机数生成器
        Random r = new Random();

        //随机数模拟投;骰子六次情况，并将次数存入到map集合中
        //键为点数，值为点数的个数
        for (int i = 0; i < 6; i++) {
            int index = r.nextInt(6)+1;
            nums.put(index, nums.get(index) + 1);
        }

        //将生成的结果返回给Result,将map的值取出来赋值给Result
        return new Result(nums.get(1),nums.get(2),nums.get(3),nums.get(4),nums.get(5),nums.get(6));
    }
}
